<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller;
use App\User;
class HomeController extends Controller
{
    /**
     * 首页
     */
    public function index()
    {
//       $user = DB::table('users')->find(1);
        $Article = DB::table('Article')->get();
        
        return view('home.index')->with([
            'article'=>$Article,
        ]);
    }

    /**
     * 留言
     */
    public function message()
    {
//        Input::all();
        return view('home.message');
    }
    //添加用户
    public function useradd()
    {
        
        return view('home.useradd');
    }
    //添加用户
    public function useradd1(Request $Request)
    {
        $input = $Request->all();
        $data = [
            'user_name' => $input['username'],
            'email'     => $input['email'],
            'password'  => $input['password'],
            'content'   => $input['content'],
            'sex'       => $input['sex'],
            'aihao'     => $input['aihao'],
        ];
        DB::table('Users')->insert($data);
        return $input;
//        return view('home.useradd');
    }
    //发表评论
    public function comment(){
        return view('home.comment');
    }
    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}
